//
//  UIView+currentVC.m
//  Pods-ToolUtil_Example
//
//  Created by 露露 on 2017/10/10.
//

#import "UIView+currentVC.h"

@implementation UIView (currentVC)
/** 获取当前view所在的viewController */
- (UIViewController *)getCurrentViewController
{
    for (UIView *next = [self superview]; next; next = next.superview) {
        UIResponder *nextResponder = [next nextResponder];
        if ([nextResponder isKindOfClass:[UIViewController class]])
        {
            UIViewController *vc = (UIViewController *)nextResponder;
            return vc;
        }
    }
    
    return nil;
}
@end
